package com.ty.blog.service.blog.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ty.blog.common.utils.PageUtils;
import com.ty.blog.common.utils.Query;
import com.ty.blog.dao.LabelDao;
import com.ty.blog.dto.req.LabelEntityReq;
import com.ty.blog.entity.LabelEntity;
import com.ty.blog.service.blog.BaseService;
import com.ty.blog.service.blog.LabelService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

@Slf4j
@Service("xBlogLabelService")
public class LabelServiceImpl extends ServiceImpl<LabelDao, LabelEntity>
    implements LabelService, BaseService<LabelEntity, LabelEntityReq> {

  @Override
  public PageUtils queryPage(LabelEntityReq req) {
    // 组装查询对象
    Wrapper<LabelEntity> queryWrapper = buildQueryWrapper(req);
    IPage<LabelEntity> page =
        this.page(
            // 组装分页对象
            new Query<LabelEntity, LabelEntityReq>().getPage(req), queryWrapper);
    return new PageUtils(page);
  }
}
